package com.synnex.mobile.servier.web.activeRecord.controller.mobile;

import com.synnex.mobile.generic.core.exception.SystemException;
import com.synnex.mobile.generic.core.json.JSONModel;
import com.synnex.mobile.generic.log.dao.annotation.LogClass;
import com.synnex.mobile.generic.log.dao.annotation.LogMethod;
import com.synnex.mobile.generic.web.anotation.mapping.RequestMapping;
import com.synnex.mobile.generic.web.view.ModelAndView;
import com.synnex.mobile.servier.core.actRecord.bo.ActivityRecordBo;
import com.synnex.mobile.servier.web.activeRecord.controller.AbstractActiveRecordController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author kerryf
 */
@RequestMapping(url = "/mobile")
@LogClass(name = "mobile activity record")
public class MobileActiveRecordController extends AbstractActiveRecordController {

    private static  String[] EXCLUDE_PROPERTIES = new String[]{"updateDate","entryDate","id","seq","type"};

    @RequestMapping(url = "/record/listrecord.do")
    @LogMethod(name = "get activity record list ")
    public ModelAndView listActRecord(HttpServletRequest request, HttpServletResponse response) {
        try {

            JSONModel jsonModel = JSONModel.create().setExcludes(EXCLUDE_PROPERTIES);
            Map<String, Object> model = new HashMap<String, Object>();
            String cate = request.getParameter("cate");
            List<Map<String, Object>> recordBosForDate = actRecordService.listRecordToClient(cate);
            model.put("results", recordBosForDate);
            jsonModel.setData(model)  ;
            return createJSONModelAndView(jsonModel);

        } catch (Exception e) {
            return createErrorJSONModelAndView(e);
        }
    }

}
